package com.pda.xinma.ui.home;

import android.view.View;
import android.widget.ImageView;
import android.widget.RelativeLayout;
import android.widget.TextView;

import com.pda.xinma.R;
import com.pda.xinma.bean.ScanResultBean;
import com.pda.xinma.contract.HomeContract;
import com.pda.xinma.presenter.HomePresenter;
import com.pda.xinma.utils.UserUtils;
import com.pda.xinma.view.pagerview.MenuPagerView;
import com.scwang.smartrefresh.layout.api.RefreshLayout;
import com.scwang.smartrefresh.layout.listener.OnRefreshListener;
import com.wangshen.base.app.AppActivityKey;
import com.wangshen.base.ui.mvp.base.ui.BaseMvpFragment;

import java.util.ArrayList;
import java.util.List;

import butterknife.BindView;
import butterknife.OnClick;


public class HomeFragment extends BaseMvpFragment<HomePresenter> implements HomeContract.View, OnRefreshListener, MenuPagerView.onItemClickListener {
    @BindView(R.id.iv_admin)
    ImageView ivAdmin;
    @BindView(R.id.tv_admin)
    TextView tvAdmin;
    @BindView(R.id.tv1)
    TextView tv1;
    @BindView(R.id.switch_warehouse)
    RelativeLayout switchWarehouse;
    @BindView(R.id.tv_total_location)
    TextView tvTotalLocation;
    @BindView(R.id.tv_used)
    TextView tvUsed;
    @BindView(R.id.tv_occupancy_rate)
    TextView tvOccupancyRate;
    @BindView(R.id.home_mpv)
    MenuPagerView homeMpv;

    List<String> list=new ArrayList<>();
    @Override
    public HomePresenter getPresenter() {
        return new HomePresenter();
    }


    @Override
    public int getViewId() {
        return R.layout.fragment_home;
    }

    @Override
    public void initView() {
        tvAdmin.setText(UserUtils.getInstance().getUserBean().getUserName());
    }

    @Override
    public void initLinsenterner() {

    }

    @Override
    public void getData() {

        list.add("手工入库");
        list.add("手工出库");
        list.add("退库");
        list.add("空桶入库");
        list.add("空桶出库");
        list.add("盘库");
        list.add("出库签收");
        homeMpv.initData(list,3);
        homeMpv.setOnItemListener(this);
    }

  /*  @Override
    public void setStorageUseInfo(StorageInfoBean storageInfoBean) {
        smart.finishRefresh();
        tvTotalLocation.setText(getResources().getString(R.string.overall_seat) + storageInfoBean.getTotal());
        tvUsed.setText(getResources().getString(R.string.have_been_used) + storageInfoBean.getUsedNum());
        tvOccupancyRate.setText(getResources().getString(R.string.occupancy_rate) + storageInfoBean.getUsage());
    }*/

    @Override
    public void showMessage(String msg) {
        super.showMessage(msg);
        //smart.finishRefresh();
    }
    @Override
    public void onRefresh(RefreshLayout refreshLayout) {
        //presenter.storageUseInfo();
    }

    @OnClick({R.id.iv_admin, R.id.tv_admin})
    public void onViewClicked5(View view) {
/*
        ConfrimDialog confrimDialog = new ConfrimDialog(mContext, new ConfrimDialog.Onclick() {
            @Override
            public void onConfirm() {
                startIntent(AppActivityKey.LOGIN);
                finishActivity();-
            }
        });
        confrimDialog.show(getString(R.string.out_login));*/
    }

    @Override
    public void onClick(String businessEntity) {
        switch (businessEntity){

            case "手工入库":
                startIntent(AppActivityKey.HANDINGINLISTTABACTIVITY);
                break;
            case "手工出库":
                startIntent(AppActivityKey.HANDINGOUTLISTACTIVITY);
                break;
            case "退库":
                startIntent(AppActivityKey.BACKDEPOTTABACTIVITY);
                break;
            case "空桶入库":
                startIntent(AppActivityKey.EMPTYBARRELINACTIVITY);
                break;
            case "空桶出库":
                startIntent(AppActivityKey.EMPTYBARRELOUTACTIVITY);
                break;
            case "盘库":
                startIntent(AppActivityKey.FULLINVENTORYLISTACTIVITY);
                break;
            case "出库签收":
                startIntent(AppActivityKey.OUTSIGNACTIVITY);
                break;
        }
    }


    @Override
    public void setScanBean(ScanResultBean scanBean) {

    }
}
